Set a GDK_ERROR_CORRUPT_IMAGE error if the loader is closed while still
authorClaudio Saavedra <csaavedra@alumnos.utalca.cl>
Tue, 11 Mar 2008 21:06:59 +0000 (21:06 +0000)
committerClaudio Saavedra <csaavedra@src.gnome.org>
Tue, 11 Mar 2008 21:06:59 +0000 (21:06 +0000)
2008-03-11  Claudio Saavedra  <csaavedra@alumnos.utalca.cl>

* io-bmp.c: (gdk_pixbuf__bmp_image_stop_load): Set a
GDK_ERROR_CORRUPT_IMAGE error if the loader is closed while
still reading the headers.  (#505085)

svn path=/trunk/; revision=19757

gdk-pixbuf/ChangeLog
gdk-pixbuf/io-bmp.c

index 3c507d472cd4f559ddaea60c8f3be238d05a8bbf..d8e689776c8a1bcf3fd4abacc734e1b5d9105c6d 100644 (file)
@@ -1,3 +1,9 @@
+2008-03-11  Claudio Saavedra  <csaavedra@alumnos.utalca.cl>
+
+       * io-bmp.c: (gdk_pixbuf__bmp_image_stop_load): Set a
+       GDK_ERROR_CORRUPT_IMAGE error if the loader is closed while
+       still reading the headers.  (#505085)
+
 2008-03-11  Claudio Saavedra  <csaavedra@alumnos.utalca.cl>
 
         * io-bmp.c: (DecodeHeader): Check for the BMP header magic numbers
index 099a16d96a0c78708228a609af22226b73ac9ded..278c1ba993e22a78b36952c89638485692c479ad 100644 (file)
@@ -693,6 +693,8 @@ gdk_pixbuf__bmp_image_begin_load(GdkPixbufModuleSizeFunc size_func,
  */
 static gboolean gdk_pixbuf__bmp_image_stop_load(gpointer data, GError **error)
 {
+       gboolean retval = TRUE;
+       
        struct bmp_progressive_state *context =
            (struct bmp_progressive_state *) data;
 
@@ -707,10 +709,20 @@ static gboolean gdk_pixbuf__bmp_image_stop_load(gpointer data, GError **error)
        if (context->pixbuf)
                g_object_unref(context->pixbuf);
 
+       if (context->read_state == READ_STATE_HEADERS) {
+                if (error && *error == NULL) {
+                        g_set_error (error,
+                                     GDK_PIXBUF_ERROR,
+                                     GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
+                                     _("Premature end-of-file encountered"));
+                }
+               retval = FALSE;
+       }
+       
        g_free(context->buff);
        g_free(context);
 
-        return TRUE;
+        return retval;
 }